<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<!--<head>
    <meta charset="UTF-8">
    <title>发布博客</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/semantic-ui/2.2.10/semantic.min.css">
    <link rel="stylesheet" href="/lib/lib/editormd/css/editormd.min.css">
    <link rel="stylesheet" href="/css/my01.css">
</head>-->
<head th:replace="admin/common::NavHead('发布博客')"></head>

<body>
<!--导航条-->
<!--<nav class="ui segment inverted attached">
    <div class="ui container">
        <div class="ui inverted menu secondary stackable">
            <h1 class="ui teal header item">管理后台</h1>
            <a href="/admin/blogs" class="m-item item m-mobile-hide"><i class="home icon"></i>博客</a>
            <a href="/admin/types" class="m-item item m-mobile-hide"><i class="idea icon"></i>分类</a>
            <a href="/admin/tags" class="m-item item m-mobile-hide" ><i class="tags icon"></i>标签</a>
            <div class="right menu">
                <div class="ui dropdown item">
                    <div class="text">
                        <img src="/images/img02.jpg" alt="" class="ui avatar image">kendi
                    </div>
                    <i class="dropdown icon"> </i>
                    <div class="menu">
                        <a href="#" class="item">用户信息</a>
                        <a href="#" class="item">修改密码</a>
                        <a href="/admin/outlog" class="item">退出登录</a>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <a href="" class="black t_menu icon ui button m-mobile-show m-right-top ">
        <i class="sidebar icon"></i>
    </a>
</nav>-->
<nav th:replace="admin/common::NavMenu"></nav>
<!--发布列表-->
<div class="ui pointing attached menu">
    <div class="ui container">
        <div class="ui right menu">
        <a href="" class="ui item  ">发布</a>
        <a href="" class="ui item active teal">列表</a>
        </div>
    </div>
</div>
<!--中间部分-->
<div class="m-container-small m-padded-tb-big">
    <div class="ui container">
        <!--表单-->
        <form action="/admin/blogs" th:object="${blog}" id="blog-form" method="post" class="ui form">
            <input type="hidden" name="published" th:value="*{published}">
            <input type="hidden" name="id" th:value="*{id}">
            <!--下拉框+标题-->
            <div class="required field">
                <div class="ui left labeled input">
                    <div class="ui selection compact teal basic dropdown label">
                        <input type="hidden" value="原创" name="flag" th:value="*{flag}">
                        <i class="dropdown icon"></i>
                        <div class="text">原创</div>
                        <div class="menu">
                            <div class="item" data-value="原创">原创</div>
                        <div class="item" data-value="转载">转载</div>
                        <div class="item" data-value="翻译">翻译</div>
                        </div>
                    </div>
                    <input type="text" name="title" placeholder="标题" th:value="*{title}">
                </div>
            </div>
            <div class="required field">
                <div id="md-content" style="z-index: 1 !important;">
                <textarea name="content" th:text="*{content}" placeholder="填写博客内容......" style="display: none">

                </textarea>
                </div>
            </div>
            <div class="required field">
                <textarea name="description" th:text="*{description}"id="description" placeholder="填写博客描述信息">

                </textarea>
            </div>
            <div class="two fields">
                <!--分类-->
                <div class="required field">
                    <div class="ui left labeled active input">
                        <label class="ui mini compact teal basic label">分类</label>
                        <div class="ui fluid  selection dropdown">
                            <input type="hidden" name="type.id" th:value="*{type}!=null ? *{type.id}">
                            <i class="dropdown icon"></i>
                            <div class="default text">分类</div>
                            <div class="menu">
                                <div th:each="type : ${types}" class="item" data-value="1" th:data-value="${type.id}" th:text="${type.name}">错误日志</div>
                            </div>
                        </div>

                    </div>
                </div>
                <!--标签-->
                <div class="field">
                    <div class="ui left labeled active input">
                        <label class="ui mini compact teal basic label">标签</label>
                        <div class="ui fluid  selection multiple dropdown">
                            <input type="hidden" name="tagIds" th:value="*{tagIds}">
                            <i class="dropdown icon"></i>
                            <div class="default text">标签</div>
                            <div class="menu">
                                <div th:each="tag : ${tags}" class="item" data-value="1" th:data-value="${tag.id}" th:text="${tag.name}">错误日志</div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="fields">
                <div class="field">
                    <div class="ui checkbox">
                        <input type="checkbox" name="recommend" th:checked="*{recommend}" id="recommend" class="hidden">
                        <label for="recommend">推荐</label>
                    </div>
                </div>
                <div class="field">
                    <div class="ui checkbox">
                        <input type="checkbox" name="shareStatement" th:checked="*{shareStatement}" id="shareStatement" class="hidden">
                        <label for="shareStatement">转载声明</label>
                    </div>
                </div>
                <div class="field">
                    <div class="ui checkbox">
                        <input type="checkbox" name="appreciation"  th:checked="*{appreciation}" id="appreciation" class="hidden">
                        <label for="appreciation">赞赏</label>
                    </div>
                </div>
                <div class="field">
                    <div class="ui checkbox">
                        <input type="checkbox" name="commentabled" th:checked="*{commentabled}" id="commentabled" class="hidden">
                        <label for="commentabled">评论</label>
                    </div>
                </div>
            </div>
            <div class="field">
                <div class="ui left mini labeled input">
                    <div class="ui  compact teal basic label">
                        <div class="text">首图</div>
                    </div>
                    <input type="text" name="firstPicture" th:value="*{firstPicture}" id="firstPicture" placeholder="首图">
                </div>
            </div>
            <div class="ui container">
                <button class="ui button warning mini " onclick="window.history.go(-1)">返回</button>
                <button id="save-btn" class="ui button basic mini">保存</button>
                <button id="publish-btn" class="ui button mini teal">发布</button>
            </div>
        </form>
    </div>
</div>

<!--页脚-->
<!--<footer class="ui inverted vertical segment m-shadow-small m-padded-mini">
    <div class="ui center aligned container" >
        <div class="ui inverted divided stackable grid" >
            <div class="three wide column">
                <div class="ui inverted link list">
                    <div class="item">
                        <img src="/images/wechat.jpg" class="ui rounded image" alt="" style="width: 110px">
                    </div>
                </div>
            </div>
            <div class="three wide column">
                <h4 class="ui inverted header m-text-thin m-text-spaced " >最新博客</h4>
                <div class="ui inverted link list">
                    <a href="#" class="item m-text-thin">hadoop+spark集群搭建</a>
                    <a href="#" class="item m-text-thin">mysql数据库</a>
                    <a href="#" class="item m-text-thin">CentOS常用的终端命令</a>
                </div>
            </div>
            <div class="three wide column">
                <h4 class="ui inverted header m-text-thin m-text-spaced ">联系我</h4>
                <div class="ui inverted link list">
                    <a href="#" class="item m-text-thin">Email:1965199277@qq.com</a>
                    <a href="#" class="item m-text-thin">QQ：1965199277</a>
                </div>
            </div>
            <div class="seven wide column">
                <h4 class="ui inverted header m-text-thin m-text-spaced ">Blog</h4>
                <p class="m-text-thin m-text-spaced m-opacity-mini">这是我的个人博客、会分享关于编程、写作、思考相关的任何内容，希望可以给来到这儿的人有所帮助...</p>
            </div>
        </div>
        <div class="ui inverted section divider"></div>
        <p class="m-text-thin m-text-spaced m-opacity-tiny">Copyright © 2019</p>
    </div>

</footer>-->

</body>
<script src="https://cdn.jsdelivr.net/npm/jquery@3.2/dist/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/semantic-ui/2.2.10/semantic.min.js"></script>
<script src="/lib/lib/editormd/editormd.min.js"></script>
<script>
    //初始化Markdown编辑器
    var contentEditor;
    $(function() {
        contentEditor = editormd("md-content", {
            width   : "100%",
            height  : 640,
            syncScrolling : "single",
            path    : "/lib/lib/editormd/lib/",
        });
    });



    $("#payButton").popup({
        popup:$(".payQR.popup"),
        on:'click',
        position:"bottom center"
    })
    $(".t_menu").click(function () {
        $(".m-item").toggleClass("m-mobile-hide");
    });
    $(".ui.dropdown").dropdown({
        on:"hover"
    });
    $('.ui.form').form({
        fields : {
            title : {
                identifier: 'title',
                rules: [{
                    type : 'empty',
                    prompt: '标题：请输入博客标题'
                }]
            },
            content : {
                identifier: 'content',
                rules: [{
                    type : 'empty',
                    prompt: '标题：请输入博客内容'
                }]
            },
            typeId : {
                identifier: 'type.id',
                rules: [{
                    type : 'empty',
                    prompt: '标题：请输入博客分类'
                }]
            },
            firstPicture : {
                identifier: 'firstPicture',
                rules: [{
                    type : 'empty',
                    prompt: '标题：请输入博客首图'
                }]
            }
        }
    });
    $("#save-btn").click(function () {
        $('[name="published"]').val(false);
        $('#blog-form').submit();
    });
    $("#publish-btn").click(function () {
        $('[name="published"]').val(true);
        $('#blog-form').submit();
    });

</script>
</html>